<template>
  <div class="main">
    <div class="register-form">
      <van-field v-model="form.Email" label="邮箱" placeholder="请输入邮箱" />
      <div style="margin: 20px">
        <van-button block type="info" @click="onSubmit">提交</van-button>
      </div>
    </div>
  </div>
</template>

<script>
import { Toast, Form } from "vant";

var wait = 60;
export default {
  components: {},
  data() {
    return {
      form: {
        Email: "",
      },
    };
  },
  methods: {
    // 表单提交
    onSubmit() {
      let reg = /^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/;
      // let reg=/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
      if (!reg.test(this.form.Email)) {
        this.$toast("请输入正确的邮箱");
        return;
      }

      this.$axios
        .post("/UserUser/ChangeEmail", this.form)
        .then((res) => {
          if (!res.success) return false;
          Toast.success("修改成功");
          setTimeout(() => {
            this.$router.goRefresh();
          }, 1500);
        })
        .catch((err) => {
          console.log("失败");
        });
    },
  },
};
</script>

<style lang="less" scoped>
.register-form {
}
.phone {
  position: relative;
  .code {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 12px;
  }
}
</style>

